Function to calculate the correlation coefficient between two real vectors
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(inout), | dimension(:) | :: | x |
Real arrays |
|
real(kind=wp), | intent(inout), | dimension(:) | :: | y |
Real arrays |
Real value with the correlation coefficient
function correlation_coefficient(x,y) result(cor) !============================================================================================ !! Function to calculate the correlation coefficient between two real vectors real(kind=wp),dimension(:),intent(inout) :: x,y !! Real arrays real(kind=wp) :: cor !! Real value with the correlation coefficient integer :: ndat real(kind=wp) :: cov ! ndat=size(x); cov=(sum((x-mean(x))*(y-mean(y)))/dble(ndat)); cor=cov/(std(x)*std(y)); end function correlation_coefficient